using System;
using Volo.Abp.Domain.Entities.Auditing;

namespace CKY.AgentPlatform.Mcp
{
    /// <summary>
    /// MCP服务器实体
    /// </summary>
    public class McpServer : AuditedAggregateRoot<Guid>
    {
        /// <summary>
        /// 服务器名称
        /// </summary>
        public virtual string Name { get; set; }

        /// <summary>
        /// 服务器描述
        /// </summary>
        public virtual string Description { get; set; }

        /// <summary>
        /// 服务器类型
        /// </summary>
        public virtual string ServerType { get; set; }

        /// <summary>
        /// 服务器主机
        /// </summary>
        public virtual string Host { get; set; }

        /// <summary>
        /// 服务器端口
        /// </summary>
        public virtual int Port { get; set; }

        /// <summary>
        /// 服务器状态
        /// </summary>
        public virtual string Status { get; set; }

        /// <summary>
        /// 是否激活
        /// </summary>
        public virtual bool IsActive { get; set; }

        /// <summary>
        /// 工具数量
        /// </summary>
        public virtual int ToolCount { get; set; }

        /// <summary>
        /// 资源数量
        /// </summary>
        public virtual int ResourceCount { get; set; }

        /// <summary>
        /// 最后连接时间
        /// </summary>
        public virtual DateTime? LastConnectedAt { get; set; }

        protected McpServer()
        {
            Name = string.Empty;
            Description = string.Empty;
            ServerType = string.Empty;
            Host = string.Empty;
            Status = "Disconnected";
            IsActive = true;
            ToolCount = 0;
            ResourceCount = 0;
        }

        public McpServer(
            Guid id,
            string name,
            string description,
            string serverType,
            string host,
            int port) : base(id)
        {
            Name = name;
            Description = description;
            ServerType = serverType;
            Host = host;
            Port = port;
            Status = "Disconnected";
            IsActive = true;
            ToolCount = 0;
            ResourceCount = 0;
        }

        /// <summary>
        /// 设置最后修改时间
        /// </summary>
        public virtual void SetLastModificationTime(DateTime time)
        {
            LastModificationTime = time;
        }

        /// <summary>
        /// 设置最后连接时间
        /// </summary>
        public virtual void SetLastConnectedTime(DateTime time)
        {
            LastConnectedAt = time;
        }
    }
}